package com.lwei.tallybook.service.vo.response;

import com.lwei.tallybook.base.domain.AccountBook;
import com.lwei.tallybook.base.domain.AccountBookBill;
import com.lwei.tallybook.base.dto.AccountBillDTO;
import com.lwei.tallybook.service.vo.ResponseVO;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;
import java.util.List;

/**
 * 账单VO
 * @author sks.lwei
 */
@Getter
@ToString
public class BillResponseVO implements ResponseVO {

    /**
     * 账单uuid
     */
    private String uuid;
    /**
     * 展示截止日期
     */
    private Date date;
    /**
     * 生成日期
     */
    private Date creatDate;
    /**
     * 总费用
     */
    private double total;
    /**
     * 是否结算
     */
    private Boolean close;

    /**
     * 账单明细
     */
    private List<AccountBillDTO.Bill> bills;

    /**
     * 关联的账本
     */
    private List<AccountBook> bookList;

    private BillResponseVO() {
    }

    private BillResponseVO(AccountBillDTO dto) {
        this.uuid = dto.getBillUuid();
        this.date = dto.getDate() == null ? new Date() : dto.getDate();
        this.creatDate = dto.getCreatDate();
        this.total = dto.getTotal();
        this.close = dto.getClose();
        this.bills = dto.getBills();
        this.bookList = dto.getBookList();
    }

    public static BillResponseVO getInstance() {
        return new BillResponseVO();
    }

    public static BillResponseVO getInstance(AccountBillDTO dto) {
        return new BillResponseVO(dto);
    }
}
